Click here to Skip to main content
15,909,324 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i have to forms,the owner and the child. and i want to send data back to the parent form from the child.the data can successfully be sent to the parent form , but the problem is that the parent form opens in the new window.. and i get two windows !! but i really want the updated window not the older window, after the operation.
can some body help me with the code ???
i'll be very thankful :)
Posted

Remember! No one will write code for you. if you need help with code then you need to put your effort first then we will.. whatever,
You can go there[^] to take a look about how to Passing values between Forms.
and this Link-Inter Form Communication with Event[^] might help you
 
Share this answer
 
Hi Hanifuk ,
first you must create an overloaded constructor in form2 and a global object of form1 , your already existing default constructor is :


public Form2()
{
     InitializeComponent();
}

The global object and the overloaded constructor code will be :


public static Form1 Frm1 = new Form1();
public Form2(Form1 form)
{
     InitializeComponent();
     Frm1 = form;
}


Now you can set your control in form1 's modifier to public .

Then in the click add button event you will insert this code for opening form2 :


Form2 Frm2 =new Form2(this);
Frm2.show();


now in the form2 code you can update your control in form1.

I Hope this help you ,
Good luck
 
Share this answer
 
Here is example how you can send data to main form

http://bytes.com/topic/c-sharp/answers/696941-instance-name-main-form#post2769458[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900